home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / beveled-pattern-button.scm < prev    next >
Encoding:
Text File  |  2005-06-30  |  4.2 KB  |  131 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Beveled pattern button for web pages
  5. ; Copyright (C) 1997 Federico Mena Quintero
  6. ; federico@nuclecu.unam.mx
  7. ;
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 2 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. ; ************************************************************************
  22. ; Changed on Feb 4, 1999 by Piet van Oostrum <piet@cs.uu.nl>
  23. ; For use with GIMP 1.1.
  24. ; All calls to gimp-text-* have been converted to use the *-fontname form.
  25. ; The corresponding parameters have been replaced by an SF-FONT parameter.
  26. ; ************************************************************************
  27.  
  28. (define (text-width extents)
  29.   (car extents))
  30.  
  31. (define (text-height extents)
  32.   (cadr extents))
  33.  
  34. (define (text-ascent extents)
  35.   (caddr extents))
  36.  
  37. (define (text-descent extents)
  38.   (cadr (cddr extents)))
  39.  
  40. (define (script-fu-beveled-pattern-button
  41.      text text-size font text-color pattern pressed)
  42.   (let* ((text-extents (gimp-text-get-extents-fontname
  43.             text text-size PIXELS font))
  44.      (ascent (text-ascent text-extents))
  45.      (descent (text-descent text-extents))
  46.  
  47.      (xpadding 8)
  48.      (ypadding 6)
  49.  
  50.      (width (+ (* 2 xpadding)
  51.            (text-width text-extents)))
  52.      (height (+ (* 2 ypadding)
  53.             (+ ascent descent)))
  54.  
  55.      (img (car (gimp-image-new width height RGB)))
  56.      (background (car (gimp-layer-new img width height RGBA-IMAGE "Background" 100 NORMAL-MODE)))
  57.      (bumpmap (car (gimp-layer-new img width height RGBA-IMAGE "Bumpmap" 100 NORMAL-MODE)))
  58.      (textl (car
  59.          (gimp-text-fontname
  60.           img -1 0 0 text 0 TRUE text-size PIXELS font))))
  61.  
  62.     (gimp-context-push)
  63.  
  64.     (gimp-image-undo-disable img)
  65.     (gimp-image-add-layer img background 1)
  66.     (gimp-image-add-layer img bumpmap 1)
  67.  
  68.     ; Create pattern layer
  69.  
  70.     (gimp-context-set-background '(0 0 0))
  71.     (gimp-edit-fill background BACKGROUND-FILL)
  72.     (gimp-context-set-pattern pattern)
  73.     (gimp-edit-bucket-fill background PATTERN-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
  74.  
  75.     ; Create bumpmap layer
  76.  
  77.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  78.  
  79.     (gimp-context-set-background '(127 127 127))
  80.     (gimp-rect-select img 1 1 (- width 2) (- height 2) CHANNEL-OP-REPLACE FALSE 0)
  81.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  82.  
  83.     (gimp-context-set-background '(255 255 255))
  84.     (gimp-rect-select img 2 2 (- width 4) (- height 4) CHANNEL-OP-REPLACE FALSE 0)
  85.     (gimp-edit-fill bumpmap BACKGROUND-FILL)
  86.  
  87.     (gimp-selection-none img)
  88.  
  89.     ; Bumpmap
  90.  
  91.     (plug-in-bump-map 1 img background bumpmap 135 45 2 0 0 0 0 TRUE pressed 0)
  92.  
  93.     ; Color and position text
  94.  
  95.     (gimp-context-set-background text-color)
  96.     (gimp-layer-set-preserve-trans textl TRUE)
  97.     (gimp-edit-fill textl BACKGROUND-FILL)
  98.  
  99.     (gimp-layer-set-offsets textl
  100.                 xpadding
  101.                 (+ ypadding descent))
  102.  
  103.     ; Clean up
  104.  
  105.     (gimp-image-set-active-layer img background)
  106.     (gimp-image-remove-layer img bumpmap)
  107.     (gimp-image-flatten img)
  108.  
  109.     (gimp-image-undo-enable img)
  110.     (gimp-display-new img)
  111.  
  112.     (gimp-context-pop)))
  113.  
  114.  
  115. (script-fu-register "script-fu-beveled-pattern-button"
  116.             _"B_utton..."
  117.             "Beveled pattern button"
  118.             "Federico Mena Quintero"
  119.             "Federico Mena Quintero"
  120.             "July 1997"
  121.             ""
  122.             SF-STRING     _"Text"               "Hello world!"
  123.             SF-ADJUSTMENT _"Font size (pixels)" '(32 2 1000 1 10 0 1)
  124.             SF-FONT       _"Font"               "Sans"
  125.             SF-COLOR      _"Text color"         '(0 0 0)
  126.             SF-PATTERN    _"Pattern"            "Wood"
  127.             SF-TOGGLE     _"Pressed"            FALSE)
  128.  
  129. (script-fu-menu-register "script-fu-beveled-pattern-button"
  130.              _"<Toolbox>/Xtns/Script-Fu/Web Page Themes/Beveled Pattern")
  131.